
$(function(){
var guanwang={
    data:{
        page:1,
      Eng_month:["January" ,"February", "March", "April" ,"May" ,"June","July","August","September","October","November","December"]
},
  event:function () {
        var that=this;
      $("#more_news").bind("click",function () {
          JsonP({
              url:guanwangID+"index.php?s=home/news/listNewsQuery",
              data:{
                  page:that.data.page++
              },
              success:function (res) {
                  if(res.resStatus===1){
                      if(!res.isMore){
                          $("#more_news").hide();
                      }
                      console.log(res);
                      var head_string="";
                      var body_string="";
                      $.each(res.data[0].articles_list,function (i,o) {
                          if(i===0&&that.data.page===2){
                              head_string='      <div class="col-sm-6">' +
                                  '                        <a href="news_detial.html?newsId='+o.article_id+'">' +
                                  '                            <div class="news_h_t_wrap">' +
                                  '                                <p>'+res.data[0].title+'</p>' +
                                  '                                <p>'+o.time+'</p>' +
                                  '                                <p>'+o.title+'</p>' +
                                  '                                <p>'+o.profile+'</p>' +
                                  '                            </div>' +
                                  '                        </a>' +
                                  '                    </div>' +
                                  '                    <div class="col-sm-6">' +
                                  '                        <a href="news_detial.html?newsId='+o.article_id+'">' +
                                  '                        <div class="news_h_p_wrap">' +
                                  '                            <img src="'+o.images+'" alt="">' +
                                  '                        </div>' +
                                  '                        </a>' +
                                  '               </div>'
                          }else{
                              body_string+='  <div class="col-xs-12">' +
                                  '                        <a href="news_detial.html?newsId='+o.article_id+'">' +
                                  '                            <div class="new_s_t_wrap">' +
                                  '                                <div>' +
                                  '                                    <p>'+(new Date(o.time.split(" ")[0]).getDate())+'</p>' +
                                  '                                    <p>'+that.data.Eng_month[new Date(o.time.split(" ")[0]).getMonth()]+'</p>' +
                                  '                                    <p>'+new Date(o.time.split(" ")[0]).getFullYear()+'</p>' +
                                  '                                </div>' +
                                  '                                <div>' +
                                  '                                    <p>'+o.title+'</p>' +
                                  '                                    <p class="clearfix"><span>发布者:'+o.admin+'</span> <span>浏览次数:'+o.clickNum+'</span></p>' +
                                  '                                    <p>'+o.profile+'</p>' +
                                  '                                </div>' +
                                  '                            </div>' +
                                  '                        </a>' +
                                  '                    </div>'
                          }
                      });
                      $(".news_wrap").append(head_string+body_string);
                  }
              }
          });
      });
  },
  init:function () {
      var that=this;
     that.event();
      JsonP({
          url:guanwangID+"index.php?s=home/news/listNewsQuery",
          data:{
              page:that.data.page++
          },
          success:function (res) {
             if(res.resStatus===1){
                 if(!res.isMore){
                     $("#more_news").hide();
                 }
                 console.log(res);
                 var head_string="";
                 var body_string="";
                 $.each(res.data[0].articles_list,function (i,o) {
                    if(i===0&&that.data.page===2){
                        head_string='      <div class="col-sm-6">' +
                            '                        <a href="news_detial.html?newsId='+o.article_id+'">' +
                            '                            <div class="news_h_t_wrap">' +
                            '                                <p>'+res.data[0].title+'</p>' +
                            '                                <p>'+o.time+'</p>' +
                            '                                <p>'+o.title+'</p>' +
                            '                                <p>'+o.profile+'</p>' +
                            '                            </div>' +
                            '                        </a>' +
                            '                    </div>' +
                            '                    <div class="col-sm-6">' +
                            '                        <a href="news_detial.html?newsId='+o.article_id+'">' +
                            '                        <div class="news_h_p_wrap">' +
                            '                            <img src="'+o.images+'" alt="">' +
                            '                        </div>' +
                            '                        </a>' +
                            '               </div>'
                    }else{
                        body_string+='  <div class="col-xs-12">' +
                            '                        <a href="news_detial.html?newsId='+o.article_id+'">' +
                            '                            <div class="new_s_t_wrap">' +
                            '                                <div>' +
                            '                                    <p>'+(new Date(o.time.split(" ")[0]).getDate())+'</p>' +
                            '                                    <p>'+that.data.Eng_month[new Date(o.time.split(" ")[0]).getMonth()]+'</p>' +
                            '                                    <p>'+new Date(o.time.split(" ")[0]).getFullYear()+'</p>' +
                            '                                </div>' +
                            '                                <div>' +
                            '                                    <p>'+o.title+'</p>' +
                            '                                    <p class="clearfix"><span>发布者:'+o.admin+'</span> <span>浏览次数:'+o.clickNum+'</span></p>' +
                            '                                    <p>'+o.profile+'</p>' +
                            '                                </div>' +
                            '                            </div>' +
                            '                        </a>' +
                            '                    </div>'
                    }
                 });
                 $(".news_wrap").append(head_string+body_string);
             }
          }
      });
  }
};

guanwang.init();
});